<template>
  <f7-page @page:afterin="init">
    <f7-navbar title="收款资料" back-link="返回">
      <f7-nav-right>
        <f7-link href="/add-pay-type/">添加</f7-link>
      </f7-nav-right>
    </f7-navbar>
    <div class="list-box">
      <div class="collection-item main-linear-bg" v-for="(item, index) in payTypeList" :key="index">
        <div class="img-box">
          <img :src="require(`../assets/wd_00${item.type ==='1'?3:1}.png`)" alt="">
        </div>
        <div class="right-box">
          <p>{{item.name}} <span>{{item.username}}</span></p>
          <p>{{item.bank}}</p>
<!--          <h1>6210&nbsp;5841&nbsp;0000&nbsp;858</h1>-->
          <h1>{{item.bankcard | bankFilter}}</h1>

          <div class="bottom-btns-bar">
            <f7-link :href="`/add-pay-type/?id=${item.id}`">修改</f7-link>
            <f7-link @click="viewCode(item.image)" v-if="item.type === '1'">收款码</f7-link>
          </div>
        </div>
      </div>
    </div>

    <custom-modal v-model="viewImgModal">
      <img :src="codeUrl" alt="" style="margin-top: 30px">
    </custom-modal>
  </f7-page>
</template>

<script>
  import { getMemberBank } from "../api/my";

  export default {
    name: "collection-information",
    data() {
      return {
        viewImgModal: false,
        payTypeList: [],
        codeUrl: ''
      }
    },
    /*mounted() {
      this.init();
    },*/
    methods: {
      init() {
        getMemberBank().then(res => {
          this.payTypeList = res.data;
        })
      },
      viewCode(url) {
        this.codeUrl = url;
        this.viewImgModal = true;
      }
    }
  }
</script>

<style scoped lang="scss">
  .list-box {
    padding: 40px $padding;
    .collection-item {
      /*background: red;*/
      border-radius: $radius;
      height: 240px;
      box-sizing: border-box;
      padding: 50px 50px 70px;
      color: $fontColor;
      display: flex;
      position: relative;
      margin-bottom: $padding;
      .img-box {
        margin-right: 40px;
        flex: 0.2;
        img {
          width: 100%;
          height: auto;
        }
      }

      .right-box {
        flex: 1;
        p {
          padding-bottom: 5px;
          font-size: 24px;
          &:first-child {
            display: flex;
            justify-content: space-between;
          }
        }
        h1 {
          font-size: 40px;
          font-weight: normal;
          letter-spacing: -1px;
          margin-top: 5px;
        }
      }
      .bottom-btns-bar {
        position: absolute;
        bottom: 20px;
        right: 40px;
        .link {
          color: $fontColor;
          margin-left: 30px;
        }
      }
    }
  }
</style>